import axios from '@/api/fetch';
// import * as types from './types';
import SERVER from '@/api/server';

// 经销商 - 下拉框
export const getJxsSelect = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/partStocks/DealertCode`, {
    params
  });

// 收款搜索列表
export const getOrderList = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage`, {
    params
  });
// 导出excel
export const exportExcelData = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/export/excel`, {
    params,
    responseType: 'arraybuffer'
  });

// 收款记录列表
export const getReceiptRecord = (id, code, params) =>
  axios.get(
    `${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/QueryReceiveDetail/${id}/${code}
/Gathering`,
    {
      params
    }
  );

// 减免记录列表
export const getReductionRecord = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/QueryDerate/${id}/${code}/Gathering`, {
    params
  });

// 发票列表
export const getInvoiceList = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/QueryInvoice/${id}/${code}/Gathering`, {
    params
  });

// 收款明细表单
export const getReceiptsDetail = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/${id}/${code}`, {
    params
  });

// 发票类型下拉
export const getInvoiceType = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/finance/advancesReceived/findInvoiceCode`, {
    params
  });

// 维修类型下拉
export const getRepairType = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedataRepairtypes/findAllRepairType`, {
    params
  });

// 品牌 - 下拉框
export const getPinpSelect = params =>
  axios.get(`/api/basedata/vehicleProduct/brandsqueryall`, {
    params
  });

// 车系 - 下拉框(根据品牌的id)
export const getChexSelect = (brandId, params) =>
  axios.get(`/api/basedata/vehicleProduct/brandsdict/${brandId}/seriessdict`, {
    params
  });

// 车型 - 下拉框()
export const getCheModelSelect = (brandsid, seriessid, params) =>
  axios.get(`/api/basedata/vehicleProduct/brandsdict/${brandsid}/seriessdict/${seriessid}/modelsdict`, {
    params
  });

// 优惠模式下拉
export const getDiscountMode = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/discountmodes/queryDiscountMode`, {
    params
  });

// 收款明细表单
export const getWorkOrder = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/QueryBalanceDetail/${id}/${code}`, {
    params
  });

// 结算表单
export const getSettlement = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/queryPayObjPo/${id}/${code}`, {
    params
  });

// 维修项目表格
export const getRepairProject = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/queryLabourObj/${id}/${code}`, {
    params
  });

// 维修材料表格
export const getRepairMaterial = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/queryRoRepairPartByBalanceNo/${id}/${code}`, {
    params
  });

// 销售材料表格
export const getSalesPo = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/querySalesPo/${id}/${code}`, {
    params
  });

// 附加项目表格
export const getAddPo = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/queryAddPo/${id}/${code}`, {
    params
  });

// 收费对象拆分
export const getChargeObject = (id, code, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/queryPayLabourObj/${id}/${code}`, {
    params
  });

// 经手人下拉
export const getEmployee = params =>
  axios.get(`/dms.web/manage/rest/basedata/ToolBuy/Employee/Select`, {
    params
  });

// 获取收费对象余额
export const getBalance = (id, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/QueryPrePay/${id}`, {
    params
  });

// 获取销账信息
export const getReceiveDetail = (id, params) =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/queryReceiveDetail/${id}`, {
    params
  });

// 收款确定
export const saveReceInfo = params =>
  axios.put(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/gathering`, params, {
    timeout: 60000
  });

// 收款关单
export const closeOrder = params => axios.put(`${SERVER.DMSCLOUD_FINANCE}/basedata/freeSettlement/performExecute`, params);

// 减免
export const reduction = params => axios.put(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/Derate`, params);

// 收款明细编辑保存
export const editSave = params => axios.put(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/MaintainReceiveMoney`, params);

// 服务顾问
export const getServiceAdvisor = params => axios.get(`/api/sysManage/basedata/users/getUserListByRole?role=10061011`);

// 销账
export const receive = (id, params) => axios.delete(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/WriteOff/${id}`, params);
/* // 品牌 - 下拉框
export const getPinpSelect = params => axios.get(`/dms.web/customer/rest/customerManage/customerManager/brandsdicts`, { params });

// 车系 - 下拉框
export const getChexSelect = (id, params) => axios.get(`/dms.web/manage/rest/basedata/brandsdictC/${id}/seriessdictC`, { params });


// 维修备件列表
export const getWxpjList = (row, params) => {
  function toZero(flag) {
    return flag === null || flag === '' ? 0 : flag;
  }
  return axios.get(
    `${SERVER.DMSCLOUD_FINANCE}/basedata/repairProject/findRepairProjectItem/${toZero(row.MODEL_LABOUR_CODE)}/${toZero(row.LABOUR_CODE)}/${toZero(row.DOWN_TAG)}/${toZero('3LN6L5EN5HR641574')}`,
    { params }
  );
};
 */

// /basedata/gatheringManage/{receiveNo}
// 打印
export const gatheringManage = receiveNo => axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/${receiveNo}`, {});

// 二维码支付下单接口
export const generateQRCP = params => axios.post(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/generateQRCP`, params);
// 支付状态查询接口
export const queryPayResult = (tradeId, params) => axios.get(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/queryPayResult/${tradeId}`, params);
// 取消收款接口
export const cancelPayment = (tradeId, params) => axios.get(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/cancelPayment/${tradeId}`, params);

// 查询成功下单记录
export const queryDmsPayingMain = (balanceNo, params) => axios.get(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/queryDmsPayingMain/${balanceNo}`, params);
// 退款接口
export const refundAmountByTradeId = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/refundAmountByTradeId`, {
    params
  });
// pos机下单
export const generatePOS = params => axios.post(`${SERVER.DMSCLOUD_FINANCE}/finance/ReceiveMoneyByPosOrQr/generatePOS`, params);

// 系统当前所有用户
export const getDealerUser = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/getDealerUser`);

// 会员代金券查询列表
export const getCouponList = params =>
  axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/getCouponList`, {
    params
  });

// 保存代金券列表
// export const updateCouponSaveList = params =>
//   axios.get(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/`, {
//     params
//   });
export const updateCouponSaveList = params => axios.post(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/getCreservationCoupon`, params);

// 更新结算单状态为欠款结算
export const setSettmentOrderDebt = params => axios.post(`${SERVER.DMSCLOUD_FINANCE}/basedata/gatheringManage/arrearsSettlement`, params);

// 批量取消收银
export const batchCancelCollection = params => axios.post(`${SERVER.DMSCLOUD_FINANCE}/`, params);
